package com.dragoncombin.homework.Module03.Problem04;

import java.util.ArrayList;
import java.util.List;

public class StudentList {

    List<Student> students = new ArrayList<>();
    private static final StudentList stdListObj = new StudentList();

    private StudentList() {
        // 无参构造默认给成员变量students初始化
        Student s1 = new Student(1001, "张飞", 20);
        Student s2 = new Student(1002, "关羽", 21);
        Student s3 = new Student(1003, "刘备", 22);
        // 将上述对象分别放入List集合
        students.add(s1);
        students.add(s2);
        students.add(s3);
    }

    public List<Student> getStudents() {
        return students;
    }

    public static StudentList getInstance() {
        return stdListObj;
    }

}
